<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>流程项目发票信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var grid = null;
	var isAllowPay = '${isAllowPay}';
	$(function () {
		initGrid();//grid
	});
	//初始化列表
	function initGrid(){
		var params = {};
		$("#grid").ligerGrid({
			url: '<%=path%>/project/prjPrdInvoice/initflowList.do?paySchNo=${paySchNo}', 
	    	method : 'get',
	    	parms:params,
	        columns: [
	        	
	             { display: '发票号码', name: 'invoicenum', minWidth: 80 ,align:'left',
	  	            	render: function (rowdata,  value, column) { 
	  	            		var no = rowdata.invoicenum==null?" ":rowdata.invoicenum;
	  	            		var h = '';
	  	            		if(no){
	  	            			 h='<a  href="javascript:detailBtn(';
		  	                        h+="'"+rowdata.id+"'";
		  	                        h+=')">'+no+'</a>'
	  	            		}
	  	                        return h;
	  	            		},
	  	            	enabledSort:true},
	            { display: '开票日期', name: 'invoicedate', minWidth: 80 ,align:'left',enabledSort:true},
	            { display: '购方名称', name: 'purchaser', minWidth: 60,align:'left',enabledSort:true},
	            { display: '购方名称校验', name: 'purchaserck', minWidth: 60,align:'left',enabledSort:true}, 
	            { display: '发动机号', name: 'enginenum', minWidth: 60,align:'left', enabledSort:true}, 
	             { display: '发动机号校验', name: 'enginenumck', minWidth: 80,align:'left',enabledSort:true}, 	
	              { display: '车架号/VIN码', name: 'vinnum', minWidth: 100,align:'left',enabledSort:true},
	             { display: '车架号/VIN码校验', name: 'vinnumck', minWidth: 80,align:'left',enabledSort:true},
	             { display: '合计金额(价税合计)', name: 'pricetax', minWidth: 120 ,align:'left',enabledSort:true,
	            	 render: function (rowdata, rowindex, value, column) { 
	            			var h = "￥" + FormatMoney(value);
	            				if(rowdata.totLsItmAmt){
	            				if(value>=rowdata.totLsItmAmt)
		            				h=h+"足额";
		            			else
		            				h=h+"不足额";
	            				}    			
	            			
	                        return h;
	            		}
	             },
	             
		         { display: '销方名称', name: 'saler', minWidth: 60,align:'left',enabledSort:true},
		         {
		                display: '操作',
		                isSort: false,
		                width: 200,
		                align:'left',
		                render: function (rowdata, rowindex, value){
		                	  var h="";
							if (!isAllowPay || isAllowPay != '0'){
								if(rowdata.invoicenum && (rowdata.audStsCd==0||rowdata.audStsCd==1||rowdata.audStsCd==4)){

									h += '<a class="sq-button-hasicon" href="javascript:modifyBtn(';
									h += "'" + rowdata.id + "'";
									h += ')"><i class="sqBtnIco_4"></i>修改</a>';
								}
							}

		                    return h;
		                }
		            }  
	        ],
	        usePager: false,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '300',
            heightDiff: -2,
            allowUnSelectRow: true,
            alternatingRow: false,
            checkbox:false,
            rownumbers:true,
            isSingleCheck:true
	    });
		grid = liger.get("grid");
		grid.setHeight(100);
		
	}
	//格式化为人民币格式
	function renderAmt(rowdata, rowindex, value) {
        var h="￥" + FormatMoney(value)
        return h;
    }

	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	//修改发票信息
	function modifyBtn(id,dtlId,flag,audStsCd,cstNm,lsCntNo,paySchNo,paySchId, prjId,prdNm){
		var callback = function(){
			 grid.reload();
		}
		var detailFlag = false;
		var url='<%=path%>/project/prjPrdInvoice/toAddPage.do?id='+id+'&&dtlId='+dtlId+'&&prjId='+prjId+'&&paySchId='+paySchId+'&&paySchNo='+paySchNo+'&&cstNm='+cstNm+'&&prdNm='+prdNm+'&lsCntNo='+lsCntNo+'&flag='+flag
        Add_navTab( 'tab_prj_prd_invoice_modify'+id,'修改发票信息',url);

	}
	//查看发票信息
	function detailBtn(id,dtlId){
		var detailFlag = true;
		Add_navTab( 'tab_prj_prd_invoice_detail'+id,'查看发票详情','<%=path%>/project/prjPrdInvoice/toDetailPage.do?detailFlag='+detailFlag+'&&id='+id+'&&dtlId='+dtlId);
	}
	
</script>

<body class="iframeBody">
	<div class="Wrapper">
       	<div id="pageInTab" class="pageInTab">
	   	<div id="grid" class="sq-grid"></div>
		<div id="gridDiv" class="sqPanel" style="margin-bottom: 0;">
	        <div class="sqPanel_body">
	            <div id="grid" class="sq-grid"></div>
	        </div>
	    </div>
	</div>
</body>
</html>